// Set new default font family and font color to mimic Bootstrap's default styling
Chart.defaults.global.defaultFontFamily = 'Nunito', '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#858796';
// $(function (){
//   $.ajax({
//     url:"/web/book",
//     type: "GET",
//     success:function (data) {
//       console.log(JSON.stringify(data));
//
//       var  num[]
//       for(var i=0;i<data.length;i++){
//
//       }
//    aa(data.num,data.nub);
//     },
//     error:function (){
//       alert("错误");
//     }
//   });
// });
// Pie Chart Example


  var xxx = document.getElementById("myPieChart");
$.ajax({
  type : "post",
  async : true,
  url : "/user/charts",
  dataType : "json",        //返回数据形式为json
  success : function(data) {

    var myPieChart = new Chart(xxx, {
      type: 'doughnut',
      data: {
        labels: data.nn,
        datasets: [{
          data: data.xx,
          backgroundColor: ['#4e73df', '#1cc88a', '#36b9cc'],
          hoverBackgroundColor: ['#2e59d9', '#17a673', '#2c9faf'],
          hoverBorderColor: "rgba(234, 236, 244, 1)",
        }],
      },
      options: {
        maintainAspectRatio: false,
        tooltips: {
          backgroundColor: "rgb(255,255,255)",
          bodyFontColor: "#858796",
          borderColor: '#dddfeb',
          borderWidth: 1,
          xPadding: 15,
          yPadding: 15,
          displayColors: false,
          caretPadding: 10,
        },
        legend: {
          display: false
        },
        cutoutPercentage: 80,
      },
    });

  },
  error : function(errorMsg) {

  }
});